package com.gitee.elf.core.data

import com.google.gson.*
import java.lang.reflect.Type

class DataInt(var value: Int) : Data {

    override fun getValue(): Any {
        return value
    }
    override fun toString(): String {
        return value.toString()
    }


    override fun clone(): DataInt {
        return DataInt(value)
    }

    @SerializerType(DataInt::class)
    class Serializer : JsonSerializer<DataInt>, JsonDeserializer<DataInt> {

        override fun serialize(src: DataInt, typeOfSrc: Type, context: JsonSerializationContext): JsonElement {
            return JsonPrimitive(src.value)
        }

        override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): DataInt {
            return DataInt(json!!.asInt)
        }

    }
}